package com.ruoyi.web.controller.business;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TbSearchlightQueue;
import com.ruoyi.system.domain.dto.SearchlightQueueDto;
import com.ruoyi.system.service.ITbSearchlightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 探照室Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/business/searchlight")
public class TbSearchlightController extends BaseController
{
    @Autowired
    private ITbSearchlightService searchlightService;

    /**
     * 查询探照室排队列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SearchlightQueueDto searchlightQueue)
    {
        startPage();
        List<TbSearchlightQueue> list = searchlightService.selectTbSearchlightQueueList(searchlightQueue);
        return getDataTable(list);
    }

    /**
     * 导出探照室排队列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, SearchlightQueueDto searchlightQueue)
    {
        List<TbSearchlightQueue> list = searchlightService.selectTbSearchlightQueueList(searchlightQueue);
        ExcelUtil<TbSearchlightQueue> util = new ExcelUtil<>(TbSearchlightQueue.class);
        util.exportExcel(response, list, "探照室排队数据");
    }

    /**
     * 获取探照室排队详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(searchlightService.selectTbSearchlightQueueById(id));
    }

    /**
     * 新增探照室排队
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbSearchlightQueue searchlightQueue)
    {
        return toAjax(searchlightService.insertTbSearchlightQueue(searchlightQueue));
    }

    /**
     * 修改探照室排队
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbSearchlightQueue searchlightQueue)
    {
        return toAjax(searchlightService.updateTbSearchlightQueue(searchlightQueue));
    }

    /**
     * 删除探照室排队
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(searchlightService.deleteTbSearchlightQueueByIds(ids));
    }

    /**
     * 材料下发
     */
    @PostMapping("/issue")
    public AjaxResult issue(@RequestBody List<TbSearchlightQueue> list)
    {
        return toAjax(searchlightService.issueTbSearchlightQueue(list));
    }
}
